package com.nari.ies.ne.nw.server.activator;

import com.nari.ies.ne.nw.server.service.fileScore.IPlantScoreService;
import com.nari.ies.ne.nw.server.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
@Slf4j
public class FileScoreByDayActivator {

    @Autowired
    private IPlantScoreService plantScoreService;
    @Scheduled(cron = "0 40 0 * * ?")
    //@Scheduled(cron = "0 0/15 * * * ?")
    public void TaskFileScore(){
        log.info("-----文件算分开始-----" + new Date());

        Date dateTime = DateUtil.getYesterday();
        // dateTime为文件日期的当天0点 即昨日00:00:00
        //Date dateTime = new Date("2023/09/05");

        // 结束时间为今天00:00:00(9月6日0点)
        Date endTime = DateUtil.getNextDay(dateTime);

        int staticType=1;

        //计算昨天文件各项分数 并插入对应场站信息
        plantScoreService.getPlantDataScoreByYesterday(endTime);

        //计算昨天文件分数 并插入对应场站信息
        plantScoreService.getPlantScoreByYesterday(endTime);

        //根据场站信息并插入对应区域信息
        plantScoreService.getAreaAVGScore(dateTime,endTime,staticType);

        //根据场站信息并插入对应阳江信息
        plantScoreService.getYJAVGScore(dateTime,endTime,staticType);

    }

}
